/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cse308.entities;

import cse308.GeneralEntity;
import cse308.helper_classes.GeneralTest;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Aaron
 */
@Entity
@Table(catalog = "nchorn", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Courseoutcomedirectassessment.findAll", query = "SELECT c FROM Courseoutcomedirectassessment c"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByCourseOutcome", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.courseOutcome = :courseOutcome"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByAssessmentInstrument", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.assessmentInstrument = :assessmentInstrument"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByThresholdScore", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.thresholdScore = :thresholdScore"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByRationale", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.rationale = :rationale"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByAttainmentLevel", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.attainmentLevel = :attainmentLevel"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByCourse", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.courseoutcomedirectassessmentPK.course = :course"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findBySection", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.courseoutcomedirectassessmentPK.section = :section"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findBySemester", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.courseoutcomedirectassessmentPK.semester = :semester"),
    @NamedQuery(name = "Courseoutcomedirectassessment.findByCourseoutcomeIdentifier", query = "SELECT c FROM Courseoutcomedirectassessment c WHERE c.courseoutcomedirectassessmentPK.courseoutcomeIdentifier = :courseoutcomeIdentifier")})
public class Courseoutcomedirectassessment implements Serializable, GeneralEntity {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected CourseoutcomedirectassessmentPK courseoutcomedirectassessmentPK;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(nullable = false, length = 20)
    private String courseOutcome;
    @Size(max = 20)
    @Column(length = 20)
    private String assessmentInstrument;
    private Integer thresholdScore;
    @Size(max = 120)
    @Column(length = 120)
    private String rationale;
    private Integer attainmentLevel;
    @JoinColumn(name = "courseoutcomeIdentifier", referencedColumnName = "identifier", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false)
    private Courseoutcome courseoutcome;
    @JoinColumns({
        @JoinColumn(name = "course", referencedColumnName = "course", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "section", referencedColumnName = "section", nullable = false, insertable = false, updatable = false),
        @JoinColumn(name = "semester", referencedColumnName = "semester", nullable = false, insertable = false, updatable = false)})
    @ManyToOne(optional = false)
    private Courseoffering courseoffering;

    public Courseoutcomedirectassessment() {
    }

    public Courseoutcomedirectassessment(CourseoutcomedirectassessmentPK courseoutcomedirectassessmentPK) {
        this.courseoutcomedirectassessmentPK = courseoutcomedirectassessmentPK;
    }

    public Courseoutcomedirectassessment(CourseoutcomedirectassessmentPK courseoutcomedirectassessmentPK, String courseOutcome) {
        this.courseoutcomedirectassessmentPK = courseoutcomedirectassessmentPK;
        this.courseOutcome = courseOutcome;
    }

    public Courseoutcomedirectassessment(String course, int section, String semester, String courseoutcomeIdentifier) {
        this.courseoutcomedirectassessmentPK = new CourseoutcomedirectassessmentPK(course, section, semester, courseoutcomeIdentifier);
    }

    public CourseoutcomedirectassessmentPK getCourseoutcomedirectassessmentPK() {
        return courseoutcomedirectassessmentPK;
    }

    public void setCourseoutcomedirectassessmentPK(CourseoutcomedirectassessmentPK courseoutcomedirectassessmentPK) {
        this.courseoutcomedirectassessmentPK = courseoutcomedirectassessmentPK;
    }

    public String getCourseOutcome() {
        return courseOutcome;
    }

    public void setCourseOutcome(String courseOutcome) {
        this.courseOutcome = courseOutcome;
    }

    public String getAssessmentInstrument() {
        return assessmentInstrument;
    }

    public void setAssessmentInstrument(String assessmentInstrument) {
        this.assessmentInstrument = assessmentInstrument;
    }

    public Integer getThresholdScore() {
        return thresholdScore;
    }

    public void setThresholdScore(Integer thresholdScore) {
        this.thresholdScore = thresholdScore;
    }

    public String getRationale() {
        return rationale;
    }

    public void setRationale(String rationale) {
        this.rationale = rationale;
    }

    public Integer getAttainmentLevel() {
        return attainmentLevel;
    }

    public void setAttainmentLevel(Integer attainmentLevel) {
        this.attainmentLevel = attainmentLevel;
    }

    public Courseoutcome getCourseoutcome() {
        return courseoutcome;
    }

    public void setCourseoutcome(Courseoutcome courseoutcome) {
        this.courseoutcome = courseoutcome;
    }

    public Courseoffering getCourseoffering() {
        return courseoffering;
    }

    public void setCourseoffering(Courseoffering courseoffering) {
        this.courseoffering = courseoffering;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (courseoutcomedirectassessmentPK != null ? courseoutcomedirectassessmentPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Courseoutcomedirectassessment)) {
            return false;
        }
        Courseoutcomedirectassessment other = (Courseoutcomedirectassessment) object;
        if ((this.courseoutcomedirectassessmentPK == null && other.courseoutcomedirectassessmentPK != null) || (this.courseoutcomedirectassessmentPK != null && !this.courseoutcomedirectassessmentPK.equals(other.courseoutcomedirectassessmentPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "cse308.entities.Courseoutcomedirectassessment[ courseoutcomedirectassessmentPK=" + courseoutcomedirectassessmentPK + " ]";
    }
    @Override
    public List<List<GeneralEntity>> getAssociatedClasses() {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public List<GeneralEntity> getAssociatedClass(String associated) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void setWithClass(GeneralTest gt) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public void testAddClass(GeneralEntity ge) {
        if(ge instanceof Courseoffering){
            this.courseoffering=(Courseoffering)ge;
        }
    }

    @Override
    public void removeClass(GeneralEntity ge) {
        if(ge instanceof Courseoffering){
            this.courseoffering=null;
        }
    }

    @Override
    public GeneralEntity findCorrespondingEntity() {
        return this;
    }

    @Override
    public String getIdentifier2() {
        String identifier2 = "";
        identifier2+=this.courseoutcomedirectassessmentPK.getCourseoutcomeIdentifier()+" "+
                this.courseoutcomedirectassessmentPK.getCourse()+" "+
                this.courseoutcomedirectassessmentPK.getSemester()+" "+
                this.courseoutcomedirectassessmentPK.getSection();
        return identifier2;
    }

    @Override
    public boolean equalsEntity(GeneralEntity entity) {
        return this.equals(entity);
    }

    @Override
    public Object getPK() {
        return this.courseoutcomedirectassessmentPK;
    }

}
